Expand description
This crate is a reimplementation of GNU gettext translation framework in Rust. It allows your Rust programs to parse out GNU MO files containing translations and use them in your user interface.
It contains several differences from the official C implementation. Notably, this crate does not in any way depend on a global locale (2.2) and does not enforce a directory structure for storing your translation catalogs (11.2.3). Instead, the choice of translation catalog to use is explicitly made by the user.
This crate is still in-progress and may not be on par with the original implementation feature-wise.
For the exact feature parity see the roadmap in the README.
Example
ⓘ
extern crate gettext;
use std::fs::File;
use gettext::Catalog;
fn main() {
let f = File::open("french.mo").expect("could not open the catalog");
let catalog = Catalog::parse(f).expect("could not parse the catalog");
// Will print out the French translation
// if it is found in the parsed file
// or "Name" otherwise.
println!("{}", catalog.gettext("Name"));
}
Structs
Catalog represents a set of translation strings
parsed out of one MO file.
ParseOptions allows setting options for parsing MO catalogs.
Enums
Represents an error encountered while parsing an MO file.